const mutations = {
	setToken(state, token) {
		uni.setStorageSync('token', JSON.stringify(token))
		state.token = token
	},
	setUserInfo(state, userinfo){
		uni.setStorageSync('userinfo', JSON.stringify(userinfo))
		state.userinfo = userinfo
	},
	setUserInfoName(state, username){
		let tempuser = JSON.parse(JSON.stringify(state.userinfo)); 
		tempuser.username = username
		state.userinfo.username = username
		uni.setStorageSync('userinfo', JSON.stringify(tempuser))
	},
	setUserInfoPhoto(state, userphoto){
		let tempuser = JSON.parse(JSON.stringify(state.userinfo));
		tempuser.userphoto = userphoto
		state.userinfo.userphoto = userphoto
		uni.setStorageSync('userinfo', JSON.stringify(tempuser))
	},
	setUserInfoRoleCode(state, rolecode){
		let tempuser = JSON.parse(JSON.stringify(state.userinfo));
		tempuser.rolecode = rolecode
		state.userinfo.rolecode = rolecode
		uni.setStorageSync('userinfo', JSON.stringify(tempuser))
	},
	//删除token
	removeToken(state){
		state.token.token = ''
		state.token.tokentime = ''
		uni.removeStorage({
			key: 'token'
		})
		state.userinfo.username = ''
		state.userinfo.userphoto = ''
		state.userinfo.rolecode = ''
		uni.removeStorage({
			key: 'userinfo'
		})
	}
}
export default mutations